package jtg;

import jtg.generator.BranchCovGenerator;
import jtg.generator.DataFlowBasedGenerator;
import jtg.generator.MCDCCovGenerator;
import jtg.generator.PrimePathCovGenerator;

import java.io.File;

public class Entrance {

    public static void generate(String classPath, String className, String methodName, String coverageType) throws Exception {
        switch (coverageType.toLowerCase()) {
            case "branch":
                BranchCovGenerator generator = new BranchCovGenerator(classPath, className, methodName);
                generator.generate();
                break;
            case "mcdc":
                String javaPath = System.getProperty("user.dir")+ File.separator+"src"+
                        File.separator + "test" + File.separator + "java" +
                        File.separator + className + ".java";
                MCDCCovGenerator mcdcCovGenerator = new MCDCCovGenerator(classPath, className, methodName, javaPath);
                mcdcCovGenerator.MCDCGenerate();
                break;
            case "path":
                PrimePathCovGenerator primePathCovGenerator = new PrimePathCovGenerator(classPath, className, methodName);
                primePathCovGenerator.generate();
                break;
            case "dataflow":
                DataFlowBasedGenerator dataFlowBasedGenerator = new DataFlowBasedGenerator(classPath, className, methodName);
                dataFlowBasedGenerator.generate();
                break;
            default:
                System.out.println("Invalid coverage type: " + coverageType);
                break;
        }
    }

    public static void main(String[] args) {
        try {
            String classPath = System.getProperty("user.dir") + File.separator + "target" + File.separator + "test-classes";
            String className = "cut.LogicStructure";
            String methodName = "test3";
            String coverageType = "branch";
            generate(classPath, className, methodName, coverageType);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
